﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using Model;

namespace DAL
{
    public class ToolRoom : BaseRepository<ToolRoomInfo>
    {
        #region 静态变量定义部分
        private const string PARM_ID = "@ID";
        private const string PARM_ROOMNAME = "@RoomName";
        #endregion

        public override IList<ToolRoomInfo> LoadEntities()
        {
            return ExcuteSqlToGetEntities("tb_ToolRoom_GetAll", null);
        }


        #region 重写基类部分
        public override string GetUpdatesp()
        {
            return "tb_ToolRoom_Update";
        }

        public override ToolRoomInfo GetEntityRecord(SqlDataReader rdr)
        {
            ToolRoomInfo cinfo = new ToolRoomInfo
            {
                ID = rdr.GetInt32(0),
                ItemName = rdr.GetValue(1).ToString(),
                RoomName = rdr.GetValue(2).ToString(),
            };
            return cinfo;
        }

        public override ToolRoomInfo GetEntityRecord()
        {
            ToolRoomInfo cinfo = new ToolRoomInfo();
            return cinfo;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter param = new SqlParameter(PARM_ID, SqlDbType.Int, 4);
            return param;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = new SqlParameter[]
                {
                    new SqlParameter(PARM_ID, SqlDbType.Int, 4),
                    new SqlParameter(PARM_ROOMNAME, SqlDbType.NVarChar,10)
                };
            return parms;
        }

        public override void SetParameters(ToolRoomInfo Entity, params SqlParameter[] Parms)
        {
            Parms[0].Value = Entity.ID;
            Parms[1].Value = Entity.RoomName;
        }

        #endregion
    }
}
